package com.yxhl.km.module.person.mvp;

import com.yxhl.km.module.person.entity.UploadBean;
import com.yxhl.km.module.person.entity.UserInfo;
import com.yxhl.km.mvp.BaseView;

import java.io.File;
import java.util.List;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

/**
 * Created by 张亚楠 on 2018/5/21.
 * 通过p层将View层和Model进行关联
 */

public class PersonPrensenter {
    private BaseView loginView;
    private PersonMoudle personMoudle;

    public PersonPrensenter(BaseView loginView) {
        this.loginView = loginView;
        this.personMoudle = new PersonMoudle();
    }

    /**
     * 查询个人信息
     *
     * @param userId
     */
    public void getUserData(String userId) {
        this.personMoudle.getData(userId, new ResultBean<UserInfo>() {
            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onResult(UserInfo userInfoBean) {
                loginView.onResult(userInfoBean);
            }

        });

    }

    /**
     * 上传头像
     *
     * @param parts
     */
    public void getUserHeadImagData(List<MultipartBody.Part> parts) {
        this.personMoudle.getUploadHeadData(parts, new ResultBean<UploadBean>() {
            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onResult(UploadBean userInfoBean) {
                loginView.onResult(userInfoBean);
            }

        });

    }


}
